<?php

class AutocompleteWidget extends CWidget
{
    public $action;
    public $id;
    public $form;
    public $model;
    public function init()
    {
    	$value = '{}';
    	if ($this->model != null) {
    		if ($this->id == "id_khachhang") {
    			$value = "{'value': '{$this->model->khachhang->ten}','id':{$this->model->khachhang->id}}";
    		}else if ($this->id == "id_doitac") {
                if ($this->model instanceof Doitac) {
                    $value = "{'value': '{$this->model->ten}','id':{$this->model->id}}";
                }else{
                    $value = "{'value': '{$this->model->doitac->ten}','id':{$this->model->doitac->id}}";
                }
    		}
    	}
        $this->render('autocomplete',array('value'=>$value));
    }
}

?>